#include<iostream>
using namespace std;
class A{
	public:
		virtual void print (){cout<<"A::print"<<endl;}
};
class B:public A{
	public:
		virtual void print (){cout<<"B::print"<<endl;}
};
class D:public A{
	public:
		virtual void print (){cout<<"D::print"<<endl;}
};
class E:public B{
	public:
		virtual void print (){cout<<"E::print"<<endl;}
};
int main() {
A a; B b; E e; D d;
A * pa = &a; B * pb = &b; 
D * pd = &d ; E * pe = &e; 
pa->print();
pa = pb; 
pa -> print(); 
pa = pd;
pa -> print(); 
pa = pe;
pa -> print(); 
return 0;
}